package com.example.campus.mapper;

import com.example.campus.pojo.dto.InfoPageQueryDTO;
import com.example.campus.pojo.dto.InfoStatusDTO;
import com.example.campus.pojo.entity.LostAndFoundInfo;
import com.example.campus.pojo.vo.LostAndFoundInfoVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface LostAndFoundInfoMapper {

    Page<LostAndFoundInfoVO> getInfoList(InfoPageQueryDTO infoPageQueryDTO);

    @Delete("delete from lost_and_found_info where id = #{infoId}")
    void deleteById(Long infoId);

    @Select("select * from lost_and_found_info where id = #{infoId}")
    LostAndFoundInfo getById(Long infoId);

    void insert(LostAndFoundInfo info);

    void update(LostAndFoundInfo info);

    @Update("update lost_and_found_info set status = #{status} where id = #{id}")
    void changeStatus(InfoStatusDTO infoStatusDTO);

    @Select("select count(*) from lost_and_found_info where type = 'lost'")
    Long getLostInfoTotal();

    @Select("select count(*) from lost_and_found_info where type = 'found'")
    Long getFoundInfoTotal();

    @Select("select count(*) from lost_and_found_info where status = 'resolved'")
    Long getResolvedInfoTotal();

    @Select("select count(*) from lost_and_found_info where status = 'unresolved'")
    Long getUnresolvedInfoTotal();
}
